const redux = require('redux')
const thunk = require('redux-thunk')

const reducer1 = (state = {count: 0}, action) => {
  // console.log(action.type)
  switch(action.type) {
    case 'add': 
      return state.count + 1
    case 'minus':
      return state.count - 1
    default:
      return state
  }
}

const reducer2 = (state = {list: []}, action) => {
  console.log(action.type)
  switch(action.type) {
    case 'loadData':
      return {
        list: ['aa']
      }
    default:
      return state
  }
}

const store = redux.createStore(reducer1)

store.dispatch({
  type: 'add',
  payload: 'abc'
})

console.log(store.getState())

store.replaceReducer(reducer2)

store.dispatch({
  type: 'loadData',
  payload: 'abc'
})

console.log(store.getState())

// store.subscribe({x: 0})

// console.log(result)